home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / machserver / 1.098 / Include / fslclNameHash.h < prev    next >
C/C++ Source or Header  |  1990-10-15  |  4KB  |  113 lines

  1. /* fslclNameHash.h --
  2.  *
  3.  *    Definitions for the filesystem name hash table.
  4.  *
  5.  * Copyright 1990 Regents of the University of California
  6.  * Permission to use, copy, modify, and distribute this
  7.  * software and its documentation for any purpose and without
  8.  * fee is hereby granted, provided that the above copyright
  9.  * notice appear in all copies.  The University of California
  10.  * makes no representations about the suitability of this
  11.  * software for any purpose.  It is provided "as is" without
  12.  * express or implied warranty.
  13.  *
  14.  * $Header: /sprite/src/kernel/fslcl/RCS/fslclNameHash.h,v 9.2 90/10/08 15:39:26 mendel Exp $ SPRITE (Berkeley)
  15.  */
  16.  
  17.  
  18. #ifndef    _FSLCLNAMEHASH
  19. #define    _FSLCLNAMEHASH
  20.  
  21. #include <list.h>
  22.  
  23. /* 
  24.  * The hash table includes an array of bucket list headers,
  25.  * and some administrative information that affects the hash
  26.  * function and comparison functions.  The table is contrained to
  27.  * have a power of two number of entries to make the hashing go faster.
  28.  */
  29. typedef struct FslclHashTable {
  30.     struct FslclHashBucket *table;    /* Pointer to array of List_Links. */
  31.     List_Links        lruList;    /* The header of the LRU list */
  32.     int         size;        /* Actual size of array. */
  33.     int         numEntries;    /* Number of entries in the table. */
  34.     int         downShift;    /* Shift count, used in hashing 
  35.                      * function. */
  36.     int         mask;        /* Used to select bits for hashing. */
  37. } FslclHashTable;
  38.  
  39. /*
  40.  * Default size of the name hash table.
  41.  */
  42. extern fslclNameHashSize;
  43. #define FSLCL_NAME_HASH_SIZE    512
  44.  
  45. /*
  46.  * The bucket header is just a list header.
  47.  */
  48.  
  49. typedef struct FslclHashBucket {
  50.     List_Links    list;
  51. } FslclHashBucket;
  52.  
  53. /* 
  54.  * The following defines one entry in the hash table. 
  55.  */
  56.  
  57. typedef struct FslclHashEntry {
  58.     List_Links    links;        /* For the list starting at the bucket header */
  59.     FslclHashBucket *bucketPtr;    /* Pointer to hash bucket for this entry */
  60.     struct FsLruList {
  61.     List_Links links;    /* Links for the LRU list */
  62.     struct FslclHashEntry *entryPtr;    /* Back pointer needed to get entry */
  63.     } lru;
  64.     Fs_HandleHeader *hdrPtr;    /* Pointer to handle of named component. */
  65.     Fs_HandleHeader *keyHdrPtr;    /* Pointer to handle of parent directory. */
  66.     char     keyName[4];    /* Text name of this entry.  Note: the
  67.                  * actual size may be longer if necessary
  68.                  * to hold the whole string. This MUST be
  69.                  * the last entry in the structure!!! */
  70. } FslclHashEntry;
  71.  
  72. typedef struct FslclLruEntry {
  73.     List_Links    lruList;    /* This record is used to map from the LRU */
  74.     FslclHashBucket *entryPtr;    /* List back to the hash entry */
  75. } FslclLruEntry;
  76.  
  77. /*
  78.  * The following procedure declarations and macros
  79.  * are the only things that should be needed outside
  80.  * the implementation code.
  81.  */
  82.  
  83. extern FslclHashTable    fslclNameTable;
  84. extern FslclHashTable    *fslclNameTablePtr;
  85. extern Boolean        fslclNameCaching;
  86.  
  87. extern void FslclNameHashStats _ARGS_((void));
  88. extern FslclHashEntry *FslclHashLookOnly _ARGS_((FslclHashTable *table,
  89.             char *string, Fs_HandleHeader *keyHdrPtr));
  90. extern void FslclHashDelete _ARGS_((FslclHashTable *table, char *string, 
  91.             Fs_HandleHeader *keyHdrPtr));
  92. extern FslclHashEntry *FslclHashInsert _ARGS_((FslclHashTable *table, 
  93.             char *string, Fs_HandleHeader *keyHdrPtr, 
  94.             Fs_HandleHeader *hdrPtr));
  95.  
  96. #define FSLCL_HASH_LOOK_ONLY(table, string, keyHandle) \
  97.     (fslclNameCaching ? \
  98.     FslclHashLookOnly(table, string, (Fs_HandleHeader *)keyHandle) : \
  99.     (FslclHashEntry *)NIL)
  100.  
  101. #define FSLCL_HASH_INSERT(table, string, keyHandle, handle) \
  102.     if (fslclNameCaching) { \
  103.     (void)FslclHashInsert(table, string, (Fs_HandleHeader *)keyHandle, \
  104.                (Fs_HandleHeader *)handle); \
  105.     }
  106.  
  107. #define FSLCL_HASH_DELETE(table, string, keyHandle) \
  108.     if (fslclNameCaching) { \
  109.     FslclHashDelete(table, string, (Fs_HandleHeader *)keyHandle); \
  110.     }
  111.  
  112. #endif /* _FSLCLNAMEHASH */
  113.